﻿using KPIS.GERP.ESS.APP.App_UI.Commons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KPIS.GERP.ESS.APP.App_UI.Forms
{
    public partial class ESS_PrintSalarySlip : System.Web.UI.Page
    {
        Main main = new Main();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlMonth.SelectedValue = DateTime.Today.Month.ToString();
                txtYear.Text = (DateTime.Today.Year + 543).ToString();

                GenPopupSalarySlip();
            }
        }

        private void GenPopupSalarySlip()
        {
            ViewState["ParamForSalarySlip"] =
                string.Format("?token={0}&redirectPage=./ExportReport.aspx?report=SalarySlip|year={1}|month={2}",
                    SsMng.TokenUserTempData, txtYear.Text, ddlMonth.SelectedValue, false);
        }

        protected void ddlMonth_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            GenPopupSalarySlip();
        }

        protected void txtYear_TextChanged(object sender, EventArgs e)
        {
            if (txtYear.Text.Trim().Length > 0)
            {
                cmdSalarySlip.Enabled = true;
                GenPopupSalarySlip();
            }
            else
            {
                cmdSalarySlip.Enabled = false;
                main.MessageAlert(Page, "กรุณากรอกข้อมูลให้ครบถ้วน");
            }
        }
    }
}